<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .parent{
            width:300px;
            height:300px;
            background:red;
            display:flex;
            /* justify-content:设置子元素的水平方向的对齐
             */
            justify-content:center;
            /* align-items:设置子元素垂直方向居中 */
            align-items:center;
        }
        .child{
            width:100px;
            height:100px;
            background:yellow;
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>
</html>